import backtrader as bt
import akshare as ak
import pandas as pd
import datetime  #
import os.path  # 路径管理
import sys  # 获取当前运行脚本的路径 (in argv[0])
import pymysql


# 1, get akshare stock data
def get_stock_data():
    stock_hfq_df = ak.stock_zh_a_hist(
        symbol="002202", adjust="qfq", start_date="20231201", end_date="20231215"
    )
    stock_hfq_df = stock_hfq_df.iloc[:, 0:6]
    stock_hfq_df.日期 = pd.to_datetime(stock_hfq_df.日期)

    # 日期     开盘     收盘     最高     最低     成交量  成交额    振幅   涨跌幅   涨跌额   换手率
    # 列名记得这样定义好
    stock_hfq_df.columns = ["Date", "Open", "Close", "High", "Low", "Volume"]
    stock_hfq_df.set_index("Date", inplace=True)
    print(stock_hfq_df)


# 2, save data to mysql

# 3, query data from mysql

if __name__ == "__main__":
    get_stock_data()
    print("main")
